import {Component} from '@angular/core';
import {Student} from '../../service/domain/student';

/*表记它是一个组件*/
@Component({
  /*声明一个全局变量*/
  selector: 'app-message',
  /*引入模板*/
  // template: '<p>This is a message</p>'
  templateUrl: './my.component.html',
})
/*到处一个MyComponent文件,文件名后需要空格*/
export class MyComponent {
  /*变量名:类型 值*/
  message: String = 'This is a message';
  me: Student = {
    name: 'Auto',
    age: 12
  };
  group: Student[] = [{
    name: 'Auto',
    age: 12
  }, {
    name: 'Auto',
    age: 12
  }];

  /*添加方法*/
  public addStudent(name: string, age: number) {
    // let me = 10/1;
    /*定义常亮*/
    const me = 10 / 3;
    /*集合中添加属性*/
    this.group.push({
      name: name,
      age: me
    });
  }
}
